<template>
  <div class="indexBg">
    <p class="index_t1">花好月圆志愿服务队</p>
    <p class="index_t2">--志愿活动个人积分排行榜</p>
    <div class="index_con">
      <van-list
          v-model="loading"
          :finished="finished"
          @load="onLoad"
      >
        <p class="index_user"><span>排名</span><span>队员姓名</span><span>总积分</span></p>
        <div v-for="(item,index) in list" :key="index" class="index_us_con">
          <span>
            <template v-if="index==0"><img src="../assets/金.png" alt=""></template>
            <template v-if="index==1"><img src="../assets/银.png" alt=""></template>
            <template v-if="index==2"><img src="../assets/铜.png" alt=""></template>
            <template v-if="index>2">{{ index + 1 }}</template>
          </span>
          <span>{{ item.realName }}</span>
          <span>{{ item.score }}</span>
        </div>
      </van-list>
      <!--      <p class="look_all">-->
      <!--        <router-link to="/login">点击查看更多>>></router-link>-->
      <!--      </p>-->
    </div>
  </div>
</template>

<script>
import {rankingList} from "@/api/index";

export default {
  name: "index",
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      refreshing: false,
      page: {
        page: 1,
        size: 10
      }
    }
  },
  methods: {
    onLoad() {
      rankingList(this.page).then(res => {
        let data = res.records;
        if (data.length <= 0) return this.finished = true;
        this.list = data;
        this.page.page += 1;
      })
      this.loading = false;
    },
  },
}
</script>

<style scoped lang="scss">
.indexBg {
  width: 100%;
  height: 38rem;
  background: url("../assets/img1.png") no-repeat;
  background-size: 100% 100%;

  .index_t1 {
    font-size: 1.8rem;
    font-weight: bolder;
    letter-spacing: 0.5rem;
    color: white;
    padding-top: 4rem;
    padding-left: 0.2rem;
  }

  .index_t2 {
    color: white;
    font-size: 0.8rem;
    padding-top: 0.8rem;
  }

  .index_con {
    border-radius: 15px;
    margin-top: 0.5rem;
    background-color: white;
    padding-top: 1rem;
    padding-bottom: 5rem;

    p, div {
      width: 90%;
      margin: 0 auto;
    }

    .index_user {
      display: flex;
      font-size: 0.8rem;
      justify-content: space-between;
      color: rgba(107, 107, 107, 0.99);
      font-weight: 600;

      span {
        display: inline-block;
        text-align: center;

        &:first-child {
          width: 3rem;
        }

        &:nth-child(2) {
          width: 12rem;
        }

        &:last-child {
          width: 3rem;
        }
      }
    }

    .index_us_con {
      display: flex;
      justify-content: space-between;
      margin-top: 1rem;

      span {
        display: inline-block;
        text-align: center;
        font-size: 0.8rem;

        &:first-child {
          width: 3rem;

          img {
            width: 1.1rem;
          }
        }

        &:nth-child(2) {
          width: 12rem;
        }

        &:last-child {
          width: 3rem;
        }
      }
    }

    .look_all {
      font-size: 0.8rem;
      margin-top: 2rem;
    }
  }
}
</style>